refactor(native): Abstract session property provider#27253
refactor(native): Abstract session property provider#27253pramodsatya merged 1 commit intoprestodb:masterfrom
Conversation
Reviewer's GuideRefactors native session property handling by extracting shared functionality into a reusable SessionPropertiesProvider base class, relocating session-related code into a dedicated properties/session module, and wiring build/tests and utility helpers to support backend-specific implementations. Class diagram for refactored session properties provider hierarchyclassDiagram
direction LR
class SessionProperty {
- protocol::SessionPropertyMetadata metadata_
- std::optional<std::string> veloxConfig_
- std::string value_
+ SessionProperty(name std::string, description std::string, typeSignature std::string, hidden bool, veloxConfig std::optional<std::string>, defaultValue std::string)
+ protocol::SessionPropertyMetadata getMetadata()
+ std::optional<std::string> getVeloxConfig()
+ std::string getValue()
+ void updateValue(value std::string)
+ bool operator==(other SessionProperty)
}
class SessionPropertiesProvider {
<<abstract>>
# std::unordered_map<std::string, std::shared_ptr<SessionProperty>> sessionProperties_
+ ~SessionPropertiesProvider()
+ std::string toVeloxConfig(name std::string)
+ json serialize()
+ bool hasVeloxConfig(key std::string)
+ void updateSessionPropertyValue(key std::string, value std::string)
# void addSessionProperty(name std::string, description std::string, type facebook::velox::TypePtr, isHidden bool, veloxConfig std::optional<std::string>, defaultValue std::string)
}
class SessionProperties {
+ static SessionProperties* instance()
+ SessionProperties()
+ bool useVeloxGeospatialJoin()
%% all k* constants omitted for brevity in diagram per instructions to avoid ellipses, but constants exist in code
}
SessionPropertiesProvider <|-- SessionProperties
SessionPropertiesProvider o--> SessionProperty
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
@majetideepak, could you please help review this change? |
presto-native-execution/presto_cpp/main/properties/session/SessionPropertiesProvider.h
Show resolved
Hide resolved
3b1a2a5 to
13584ea
Compare
| /// Note: This interface should align with java coordinator. | ||
| class SessionProperty { | ||
| public: | ||
| SessionProperty( |
There was a problem hiding this comment.
We had issues with this class where users did not call the constructor correctly.
For example, additions were made where the "hidden" column was set to a numeric default value. This is allowed due to implicit casting and wasn't caught at the time.
Now that we are refactoring this maybe we can a property builder replacing the addSessionProperty function with a builder scheme?
This would add to this PR. Maybe it would be left to another PR but probably won't gain too much traction if not done here?
@majetideepak @pdabre12 What do you think?
There was a problem hiding this comment.
Thanks for the suggestion @czentgr, I agree this is a pending cleanup, we could go with a builder, or have presto protocol generate the cpp class for us by modifying https://github.com/prestodb/presto/blob/master/presto-spi/src/main/java/com/facebook/presto/spi/session/PropertyMetadata.java.
However as you pointed out this cleanup is orthogonal to the PR and I would prefer to take it up separately and get this refactor in first. Getting this refactor in would help unblock #27204.
There was a problem hiding this comment.
Thanks @pramodsatya.
Please address @czentgr 's suggestions in a follow-up PR.
presto-native-execution/presto_cpp/main/properties/session/tests/CMakeLists.txt
Outdated
Show resolved
Hide resolved
|
Thanks for the feedback @czentgr, addressed the comments, could you please take another look? |
b0329c3 to
dbbb52f
Compare
|
@pramodsatya can you please rebase this with master? Thanks. |
dbbb52f to
060a44a
Compare
|
Thanks @majetideepak, rebased with master, could you please review/approve again? |
060a44a to
3dc5e25
Compare
Description
Refactors session properties provider into a base class.
Motivation and Context
Different native execution backends like
cuDFcan provide their own mapping of Presto to Velox configs in order to integrate Velox configs into Presto with the native session property provider (ref).Required by #27204.
Impact
N/A.
Test Plan
Verified with existing e2e tests.
Summary by Sourcery
Refactor native session properties into a reusable provider base class and reorganize related code into a dedicated properties module.
Enhancements:
Build:
Tests: